package com._51cto.healthy.controller;


import com._51cto.healthy.constant.RoleConstant;
import com._51cto.healthy.content.R;
import com._51cto.healthy.pojo.SetMeal;
import com._51cto.healthy.pojo.User;
import com._51cto.healthy.service.OrderSettingService;
import com._51cto.healthy.service.SetMealService;
import com._51cto.healthy.service.UserService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class SetMealController {

    @DubboReference
    private SetMealService setMealService;

    @DubboReference
    private UserService userService;

    @DubboReference
    OrderSettingService orderSettingService;

    @GetMapping("/set-meal")
    public String setMeal(@RequestParam("id") Integer id ,Model model){
        System.out.println("id:"+id);
        //获取套餐详情
        // 获取套餐下所有检测组信息
        // 获取检测组下所有检测项信息
        //获取所有的信息
        SetMeal setMeal = setMealService.queryInfoByPK(id);
        List<SetMeal> setMealList = setMealService.queryHot(2);
        List<User> doctors = userService.queryByRole(RoleConstant.ROLE_HEALTH_MANAGER);
        model.addAttribute("setMealList",setMealList);
        model.addAttribute("info",setMeal);
        model.addAttribute("doctors",doctors);
        return "setmeal";
    }

    @ResponseBody
    @GetMapping("/date")
    public R date(@RequestParam("doctor") Integer doctor){
        List<String> list = orderSettingService.queryDateByDoctor(doctor);
        return R.success(list);
    }
}
